package com.cdd.servicebankcard.service.impl;

import com.cdd.servicebankcard.dao.AccountInfoMapper;
import com.cdd.servicebankcard.model.AccountInfo;
import com.cdd.servicebankcard.service.AccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description TODO
 * @Author: cdd
 * @Date: 2020/7/9 15:31
 * @Version: 1.0
 */
@Service
public class AccountServiceImpl implements AccountService {

    @Resource
    AccountInfoMapper accountInfoMapper;

    @Override
    public AccountInfo getById(Long id) {
        return accountInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateAccountById(Integer amount) {
        AccountInfo accountInfo = getById(1L);
        accountInfo.setBalance(accountInfo.getBalance() + amount);
        return accountInfoMapper.updateByPrimaryKeySelective(accountInfo);
    }


}
